﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JGLib.States;
using Microsoft.Xna.Framework.Graphics;
using System.Threading;
using TrafficTrouble.Core;
using Microsoft.Xna.Framework;

namespace TrafficTrouble.States
{
    public class LoadingState : State
    {
        private string[] LevelNames;
        private Grid[] Levels;

        public bool SwitchToGameState = false;
        public Grid GameLevel;

        public LoadingState()
            : base(typeof(LoadingState))
        {
            this.LevelNames = new string[]
            {
                
            };
            this.Levels = new Grid[this.LevelNames.Length];
        }

        protected override void LoadContent()
        {
            //int levelIndex = 0;
            //foreach (string levelName in this.LevelNames)
            //{
            //    LevelFile levelFile = new LevelFile(levelName);
            //    this.Levels[levelIndex++] = levelFile.GetLevel();
            //}
            this.LoadTexture("Loading/LoadingScreen", this);
        }

        protected override void Update(double gameTime)
        {
            if (this.SwitchToGameState) this.SwitchToState(typeof(GameState), this.GameLevel);
            else this.SwitchToState(typeof(MainMenuState));

            base.Update(gameTime);
        }

        protected override void Draw(SpriteBatch g)
        {
            // draw loading screen
            g.Draw(this.GetTexture(this), new Rectangle(0, 0, Game.Width, Game.Height), Color.White);
        }
    }
}
